<template>
	<view>
		<view class="c-box" id="personalInformation">
		    <view class="personal">
		        <view class="img" @click="choosePortraitImg()">
		            <image class="touxiang" :src="currentUser.portrait" v-if="currentUser.portrait"/>
		            <image class="touxiang" src="/static/image/wutouxiang.png" v-else/>
		            <image class="icon" src="https://m.nocexpo.com/statics/js/modules/h5/img/img14.png"/>
		            <view class="audit" v-show="currentUser.type == 1 && currentUser.state == 0 && ifBecomeExhibition">审核中</view>
		            <view class="audit" v-show="currentUser.type == 2 && currentUser.state == 2 && ifBecomeExhibition">审核未通过</view>
		        </view>
		        <view class="dl">
		            <view class="dd" v-if="currentUser.type==1&&currentUser.state==1">
		                <view class="titleWord span" style="background-color: #e6e7e8;margin-right: 0;padding-right: 50rpx">公司</view>
		                <view class="label" v-text="currentUser.company" ></view>
		            </view> 
		            <view class="dd" v-else>
		                <view class="red-star">*</view><view class="span titleWord">公司</view>
						<input type="text"  v-model="currentUser.company" placeholder="请输入您的公司名"/>
		
		            </view>
		            <view class="dd" v-if="!ifBecomeExhibition">
						<view class="red-star">*</view><view class="span titleWord">昵称</view>
						<input type="text" v-model="currentUser.userName" placeholder="请输入您的昵称"/>
		            </view>
		            <view class="dd" v-if="ifBecomeExhibition" style="align-items: center">
		                <view class="red-star" >*</view><view class="span titleWord">公司官网</view>
		                <textarea rows="2"  style="width: 100%;border: none;font-size: 30rpx;line-height: 100rpx;height: 100rpx; color: #1A1A1A;"  v-model="currentUser.companyWebsite" placeholder="请输入您的公司官网;如：www.nocexpo.com" ></textarea>
		            </view>
		            <view class="dd">
		                <view class="red-star">*</view><view class="span titleWord">姓名</view>
		                <input type="text" v-model="currentUser.nickName" placeholder="请输入您的姓名"/>
		            </view>
		         
		            <view class="dd" style="height: 200rpx;">
		                <view class="red-star">*</view><view class="span titleWord">职位</view>
		                <view style="width: 100%;">
		                   <radio-group name="choosePosition" @change="choosePosition" style="width: 100%;justify-content: flex-start;">
								<view style="display: flex;    font-size: 27rpx;">
								   <label style="display: flex;align-items: center;width: 32.5%">
										<radio value= "销售" :checked="'销售' == currentUser.position" />销售
									</label>
									<label style="display: flex;align-items: center;width: 32.5%">
										<radio value= "技术" :checked="'技术' == currentUser.position" />技术
									</label>
									<label style="display: flex;align-items: center;width: 32.5%">
										<radio value= "采购" :checked="'采购' == currentUser.position"/>采购
									</label>
								</view>
								<view style="display: flex;    font-size: 27rpx;">
									<label style="display: flex;align-items: center;width: 32.5%">
										<radio value= "厂长"  :checked="'厂长' == currentUser.position" />厂长
									</label>
									<label style="display: flex;align-items: center;width: 32.5%">
										<radio value= "总经理"  :checked="'总经理' == currentUser.position" />总经理
									</label>	
									<label style="display: flex;align-items: center;width: 32.5%">
										<radio value= "其他" :checked="'其他' == currentUser.position" />其他
									</label>
								</view>
		                   </radio-group>
		                </view>
		            </view>
		            <view class="dd" id="picker" style="height: auto;" v-if="currentUser.type == 1 && currentUser.state == 1 || ifBecomeExhibition">
		                <view class="red-star">*</view><view class="span titleWord">服务地区</view>
							<picker style="width: 100%;" mode="multiSelector" @change="bindChange" @columnchange="bindColumnChange" value="{{addressIndex}}" :range="selectAddress">
								<view v-if="showAddress.length == 0">请选择地区</view>
								<view v-else style="display: flex;">
									<view v-for="(item,index) in showAddress">
										 {{item}}
										 <image src="https://m.nocexpo.com/statics/js/modules/h5/img/icon_cha.png" style="width: 20rpx;height: 20rpx; vertical-align: super;" @click.stop="delAddress(index)"/>
									</view>
								</view>
							</picker>
							
		                   <!-- <view v-for="(item,index) in showAddress">
		                        {{item}}
		                        <image src="/static/image/icon_cha.png" style="width: 0.333333rem;vertical-align: super;" @click.stop="delAddress(index)"/>
		                    </view> -->
		            </view>
		            <view style="height: auto;color: red;" v-if="currentUser.type == 1 && currentUser.state == 1 || ifBecomeExhibition">
		                注：可多选，选择省级后则无法选择该省下的市区
		            </view>
		            <view class="dd" v-if="currentUser.type == 1 && currentUser.state == 1 || ifBecomeExhibition">
		                <view class="red-star">*</view><view class="span titleWord">公司性质</view>
						
						<picker mode="selector" @change="updateCompanyNature" value="{{index}}" :range="companyNatureList" range-key="text" style="width: 100%; border: 0; background: transparent; -webkit-appearance: none;" >
							<view v-if="index == '' || index == null">请选择</view>
						    <view v-else>{{companyNatureList[index].text}}</view>
						</picker>
						
		            </view>
		            <view class="dd" v-if="ifBecomeExhibition" >
		                <view class="red-star">*</view><view class="span">主营产品</view>
		                <input type="text" v-model="currentUser.mainProducts" placeholder="请输入主营产品"/>
		            </view>
		            <view class="dd"  v-if="!ifBecomeExhibition">
		                <view class="span titleWord">个性签名</view>
		                <textarea placeholder="写点什么吧！" v-model="currentUser.personSign" style="width: 500rpx; font-size: 30rpx; border: 0; padding: 10rpx;height: 100rpx;"></textarea>
		            </view>
		
		            <view class="uploadBox" v-if="ifBecomeExhibition">
		                <view class="tit">
		                        <view class="red-star">*</view>营业执照上传
		                </view>
		                <view class="upload imgLog2" style="width: 160rpx; height: 200rpx;">
		                    <image style="width: 100%;height: 100%;" :src="currentUser.license?currentUser.license:'https://m.nocexpo.com/statics/js/modules/h5/img/img44.jpg'" @click="chooseImg()"/>
		                    <input type="file" style="display: none" name="files" ref="license" accept="image/*" multiple="multiple" @change="chooseImg()">
		                </view>
		            </view>
		            <view class="dd" v-if="ifBecomeExhibition && currentUser.type == 2 && currentUser.state == 2" style="border-top: 1px solid #ebebeb;">
		                <view class="span titleWord" style="width: 1.87rem">未通过原因</view>
		                <input type="text" v-model="currentUser.notPassAudit" placeholder="审核未通过原因" readonly/>
		            </view>
		            <view class="dd" v-if="ifBecomeExhibition && currentUser.type == 2 && currentUser.state == 2">
		                <view style="color: red">注：审核未通过时，可做相应信息修改重新提交审核</view>
		            </view>
		
		            <view class="next" v-if="!ifBecomeExhibition" @click="submit" style="margin-top: 50rpx">完成,去体验</view>
		            <view class="next" v-else @click="becomeExhibition">提交审核</view>
		

		        </view>
		        <view class="c-h98"></view>
		    </view>
		    <view class="showbox" v-show="load">
		        <view class="loader">
		          <!--  <svg class="circular" viewBox="25 25 50 50">
		                <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10">
		                </circle>
		            </svg> -->
		        </view>
		    </view>
		</view>
	</view>
</template>

<script>
import infoApi from '@/api/updatePersonInfo.js';
import commonApi from '@/utils/commonMethod.js';
import {cityData} from "@/api/address.js";

export default {
	
	data() {
		return {
			currentUser: {},
			ifBecomeExhibition: false,
			parIntArr: [],
			proIntArr: [],
			backUrl: '',
			load: false,
			address: cityData,
			showAddress: [],
			useAddress: [],
			companyNatureList:[
				{value : '经销商',text:'经销商'},
				{value : '代理商',text:'代理商'},
				{value : '生产厂家',text:'生产厂家'},
				{value : '工程商',text:'工程商'},
				{value : '二手商家',text:'二手商家'},
				{value : '其他',text:'其他'},
			],
			index: '',

			nationArray:["全国"], //地区下拉国家
			provinceArray:[],//地区下拉省
			cityArray:[],//地区下拉城市
			selectAddress:[], //下拉地区组合
			addressIndex:[],
			addressArray:[],//
			proviceIndex:'',//地区下拉省下标
			cityIndex:'',//地区下拉城市下标
		}
	},
	onLoad(options) {
		let type = options.type
		if (type == 'becomeExhibition') {
			this.ifBecomeExhibition = true
			// document.getElementsByTagName("title")[0].innerText = '完善审核信息';
		}
		let backUrl = options.backUrl
		if(backUrl){
			this.backUrl = backUrl;
		}
		this.getCurrentUser();
	},
	
	async mounted() {
		
		

		// await getWxConfig({})

		var addressStr = JSON.stringify(this.address)
		this.addressArray = JSON.parse(addressStr)
		this.addressArray.forEach((item,index,arr) =>{
			for (let data in item) {
			   this.provinceArray.push(data);
			 }
		})

		this.selectAddress.push(this.nationArray)
		this.selectAddress.push(this.provinceArray)
		this.selectAddress.push(this.cityArray)
		
		

		let dateArr = []; // 定义一个数组来存放时间
		let nameArr = ''; // 定义一个数组来存放name
		let cost_timeArr = []; // 定义一个数组来存放cost_time
		for (let date in this.addressArray[3]) {
		   dateArr.push(date);
		   this.cityArray = this.addressArray[3][date];
		}


	},
	methods: {
		bindChange(e){
			this.selectIndex = e.detail.value
			let selectArr = []
			selectArr.push(this.nationArray[this.selectIndex[0]])
			selectArr.push(this.provinceArray[this.selectIndex[1]])
			selectArr.push(this.cityArray[this.selectIndex[2]])
			if(selectArr[2] == undefined){
				selectArr.splice(2,1,"")
			}
			 for (let i = selectArr.length-1; i >= 0 ; i--) {
				if(selectArr[i] != ""){
					if(this.checkAddress(selectArr[i],selectArr[selectArr.length-2])){
						this.showAddress.push(selectArr[i]);
						this.useAddress.push(selectArr.join("、"));
					}
					break;
				}
			}
			
		},
		bindColumnChange(e){
			
			if(1 == e.detail.column){
				let dateArr = []; // 定义一个数组来存放时间
				let nameArr = []; // 定义一个数组来存放name
				console.log(e.detail.value);
				for (let date in this.addressArray[e.detail.value]) {
				   dateArr.push(date);
				   this.cityArray = this.addressArray[e.detail.value][date];
				 }
				this.selectAddress.splice(2,1,this.cityArray)

			}
		},
		choosePortraitImg(){
			uni.chooseImage({
				count: 1, //默认9
				sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				sourceType: ['album','camera'], //从相册选择
				success: function (res) {
					var that = this
					//获取上传文件路径
					const tempFilePaths = res.tempFilePaths;
					//获取token, 上传时携带此参数，否则会被登录拦截掉
					let headers = {
					  "token": uni.getStorageSync("authorize").token,
					  cookie: uni.getStorageSync('cookie')
					};
					tempFilePaths.forEach((item,index,arr) =>{
						//上传
						uni.uploadFile({
							url: 'https://m.nocexpo.com/sys/oss/upload',
							filePath: item,
							name: 'file',
							header: headers,
							success: (response) => {
								console.log(response);
								let result = JSON.parse(response.data)
								if (result.code == 0){
									console.log(result.url);
									that.currentUser.portrait = result.url
								}
							}
						})
					})
					uni.showToast({
						title:"上传成功",
						icon:"success"
					})
					
				}.bind(this)
			});
		},
		updateCompanyNature(e){
			console.log(e);
			this.index =  e.detail.value
			this.currentUser.companyNature = this.companyNatureList[e.detail.value].value
			console.log(this.currentUser.companyNature);
		},
		choosePosition(e){
			this.currentUser.position = e.detail.value
		},
			//获取当前用户
		getCurrentUser(){
			commonApi.currentUserAxios().then(res =>{
				console.log(res);
				this.currentUser = res.data.session_user_h5;
				
				if(!this.currentUser.parInt){
					this.parIntArr.push('不限');
				}else{
					this.parIntArr = this.currentUser.parInt.split(',');
				}
				if(!this.currentUser.proInt){
					this.proIntArr.push('不限');
				}else{
					this.proIntArr = this.currentUser.proInt.split(',');
				}
				if(!this.currentUser.companyNature){
					this.currentUser.companyNature = ""
				}else{
				  this.companyNatureList.forEach((item,index,arr) =>{
					  if( item.value == this.currentUser.companyNature){
						  this.index = index
					  }
				   
					
				  })
				}
				//格式化服务地区数据
				console.log(this.currentUser);
				if(this.currentUser.serviceArea){
					this.useAddress = this.currentUser.serviceArea.split(",");
					console.log(this.useAddress);
					console.log("address");
					for (let i = 0; i < this.useAddress.length; i++) {
						let split = this.useAddress[i].split("、");
						for (let j = split.length-1; j >= 0; j--) {
							if(split[j] != ""){
								this.showAddress.push(split[j])
								console.log(this.showAddress);
								break;
							}
						}
					}
				}
				this.currentUser.userName = this.currentUser.userName == '游客'?'':this.currentUser.userName
				
			});
		},
	
		//普通修改按钮
		submit() {
			console.log("提交");
			const verifyFormResult = this.verifyForm()
			this.currentUser.serviceArea = this.useAddress.toString();
			if (verifyFormResult) {
			infoApi.updateInfo(this.currentUser).then(res => {
					if (res.data.code === 0) {
						if (!this.backUrl) {
							uni.switchTab({
								url:"/pages/tabBar/index/index"
							})
						}
						if (this.backUrl.includes("/h5login")) {
							uni.switchTab({
								url:"/pages/tabBar/index/index"
							})
						} else if (this.backUrl.includes("index") || this.backUrl.includes("cloudhome")
							|| this.backUrl.includes("cloudcomp") || this.backUrl.includes("product")
							|| this.backUrl.includes("cloudlive") || this.backUrl.includes("takePartInAct")
							|| this.backUrl.includes("dailyTask") ) {
							uni.redirectTo({
								url: this.backUrl
							})
						} else {
							uni.switchTab({
								url:"/pages/tabBar/index/index"
							})
						}
					}
				})
			}
		},
		verifyForm() {
			if (!this.currentUser.company || !this.currentUser.company.trim()) {
				uni.showModal({
					title: "提示",
					content: "请填写公司信息！",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			
				return false;
			}
			if ((!this.currentUser.companyWebsite || !this.currentUser.companyWebsite.trim()) &&  this.ifBecomeExhibition) {
				uni.showModal({
					title: "提示",
					content: "请填写公司官网！",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
				
				return false;
			}
			if (!this.currentUser.nickName || !this.currentUser.nickName.trim()) {
				uni.showModal({
					title: "提示",
					content: "请填写姓名！",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
				return false;
			}
			if (!this.currentUser.position || !this.currentUser.position.trim()) {
				uni.showModal({
					title: "提示",
					content: "请填写职位！",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
				return false;
			}
			if(this.currentUser.type == 1 && this.currentUser.state == 1 || this.ifBecomeExhibition){
				if(this.useAddress.length == 0){
					uni.showModal({
						title: "提示",
						content: "请选择服务地区",
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					
					return;
				}
				this.currentUser.serviceArea = this.useAddress.toString();
				if(!this.currentUser.companyNature){
					uni.showModal({
						title: "提示",
						content: "请选择公司性质",
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					
					
					return;
				}
			}
			if (this.currentUser.personSign) {
				if(this.currentUser.personSign.length > 50){
					uni.showModal({
						title: "提示",
						content: "签名字数不能超过50字",
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					
					return false;
				}
			}
			if(this.parIntArr.length == 0){
				uni.showModal({
					title: "提示",
					content: "请选择个人意向！",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
				
				return false;
			}
			this.currentUser.parInt =this.parIntArr.toString();
			if(this.proIntArr.length == 0){
				uni.showModal({
					title: "提示",
					content: "请选择产品意向！",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			
				return false;
			}
			this.currentUser.proInt =this.proIntArr.toString();
			return true;
		},
		//提交审核按钮
		becomeExhibition() {
			const verifyFormResult = this.verifyForm()
			if (!verifyFormResult) {
				return;
			}
			if(!this.currentUser.mainProducts){
				uni.showModal({
					title: "提示",
					content: "请填写主营产品",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
				return;
			}

			if (!this.currentUser.license) {
				uni.showModal({
					title: "提示",
					content: "请上传营业执照",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
				return;
			}
			this.currentUser.type = 1
			this.currentUser.state = 0

			//获取申请时间
			var applicationTime = new Date();

			this.currentUser.applicationTime = applicationTime;
			infoApi.updateInfo(this.currentUser).then(res => {
				if (res.data.code === 0) {
					uni.showModal({
						title: "提示",
						content: "提交成功,请等待审核",
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.switchTab({
									url:"/pages/tabBar/personal/personal"
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});

				}
			})
		},

		//上传头像功能
		// uploadPortrait(el) {
		// 	if (!el.target.files[0].size) {
		// 		layer.open({
		// 			anim: '提示',
		// 			content: '请选择图片',
		// 			btn: ['确定'],
		// 		});
		// 		return
		// 	} else {
		// 		fileList(el.target,uploadPortraitAxios)
		// 	}
		// },
		//上传图片
		uploadImg(tailorLicense){
			if(isWeiXin()){
				this.chooseImg(tailorLicense)
			}else{
				// this.$refs.license.dispatchEvent(new MouseEvent('click'));
			}
		},
		//上传营业执照功能
		//判断是否图片类型
		uploadLicense(el) {
			if (!el.target.files[0].size) {
				uni.showModal({
					title: "提示",
					content: "请选择图片",
					showCancel:false,
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				return
			} else {
				this.load = true;
				fileList(el.target,uploadLicenseAxios)
			}
		},
		/**
		 * 触发上传图片按钮
		 */
		chooseImg() {
			uni.chooseImage({
				count: 1, //默认9
				sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				sourceType: ['album','camera'], //从相册选择
				success: function (res) {
					var that = this
					//获取上传文件路径
					const tempFilePaths = res.tempFilePaths;
					//获取token, 上传时携带此参数，否则会被登录拦截掉
					let headers = {
					  "token": uni.getStorageSync("authorize").token,
					  cookie: uni.getStorageSync('cookie')
					};
					tempFilePaths.forEach((item,index,arr) =>{
						//上传
						uni.uploadFile({
							url: 'https://m.nocexpo.com/sys/oss/upload',
							filePath: item,
							name: 'file',
							header: headers,
							success: (response) => {
								let result = JSON.parse(response.data)
								if (result.code == 0){
									console.log(result.url);
									that.currentUser.license = result.url
								}
							}
						})
					})
					uni.showToast({
						title:"上传成功",
						icon:"success"
					})
		
				}.bind(this)
			});
		
				
		},
		//调用微信方法选择图片
		// chooseImg(imgLoad){
		// 	wx.chooseImage({
		// 		count: 1, // 默认9
		// 		sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
		// 		sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
		// 		success: function (res) {
		// 			let localId = res.localIds[0]
		// 			wx.getLocalImgData({
		// 				localId: localId, // 图片的localID
		// 				success: function (res) {
		// 					let localData = res.localData
		// 					this.load = true;
		// 					if (localData.indexOf('data:image') != 0) {
		// 						//判断是否有这样的头部
		// 						localData = 'data:image/jpeg;base64,' +  localData
		// 					}
		// 					localData = localData.replace(/\r|\n/g, '').replace('data:image/jgp', 'data:image/jpeg')

		// 					//生成canvas
		// 					let canvas = document.createElement('canvas');
		// 					if(canvas.getContext){
		// 						//获得渲染上下文和绘画功能
		// 						let ctx = canvas.getContext('2d');
		// 						var img = document.createElement('img');

		// 						img.onload = function(){
		// 							imgLoad(img,canvas,ctx)
		// 						}
		// 						img.onerror = function(res){
		// 							layer.open({
		// 								anim: '提示',
		// 								content: "图片加载错误"+JSON.stringify(res, ["message", "arguments", "type", "name"]),
		// 								btn: ['确定'],
		// 							});
		// 						}
		// 						img.src = localData;
		// 					}else{
		// 						layer.open({
		// 							anim: '提示',
		// 							content: "您的浏览器不支持canvas",
		// 							btn: ['确定'],
		// 						});
		// 					}
		// 				},
		// 				fail:function(res){
		// 					layer.open({
		// 						anim: '提示',
		// 						content: res,
		// 						btn: ['确定'],
		// 					});
		// 				}
		// 			});
		// 		},
		// 		fail:function(res){
		// 			layer.open({
		// 				anim: '提示',
		// 				content: res,
		// 				btn: ['确定'],
		// 			});
		// 		}
		// 	});
		// },
		//裁剪头像
		// tailorPortrait(img,canvas,ctx){
		// 	let _this = img
		// 	layer.open({
		// 		anim: '提示',
		// 		content: "正在裁剪",
		// 	});

		// 	// 创建属性节点
		// 	var anw = document.createAttribute("width");
		// 	anw.nodeValue = "200";
		// 	var anh = document.createAttribute("height");
		// 	anh.nodeValue = "200";
		// 	canvas.setAttributeNode(anw);
		// 	canvas.setAttributeNode(anh);

		// 	if(_this.width>=_this.height){
		// 		let xishu1 = 200/_this.height
		// 		ctx.drawImage(img,0,0,xishu1*_this.width,200);
		// 	}
		// 	if(_this.width<_this.height){
		// 		let xishu2 = 200/_this.width
		// 		ctx.drawImage(img,0,0,200,xishu2*_this.height);
		// 	}
		// 	let finalDataURL= canvas.toDataURL("image/jpeg", 1.0);
		// 	let finalFile = convertBase64UrlToBlob(finalDataURL)
		// 	let compressFile = {urlFile:finalFile,fileName:"wodetouxiang.jpg"};
		// 	uploadPortraitAxios(compressFile)
		// },

		//上传营业执照
		// tailorLicense(img,canvas,ctx){
		// 	let _this = img
		// 	// 创建属性节点
		// 	var anw = document.createAttribute("width");
		// 	anw.nodeValue = _this.width;
		// 	var anh = document.createAttribute("height");
		// 	anh.nodeValue = _this.height;
		// 	canvas.setAttributeNode(anw);
		// 	canvas.setAttributeNode(anh);
		// 	ctx.drawImage(img,0,0,_this.width,_this.height);
		// 	let finalDataURL= canvas.toDataURL("image/jpeg", 1.0);
		// 	let finalFile = convertBase64UrlToBlob(finalDataURL)
		// 	let compressFile = {urlFile:finalFile,fileName:"license.jpg"};
		// },
		picker(){
			console.log("picker");
			// var pickerView = new PickerView({
			// 	bindElem: document.getElementById("picker"),
			// 	data: this.address,
			// 	title: '服务地区',
			// 	leftText: '取消',
			// 	rightText: '确定',
			// 	rightFn: function( selectArr ){
			// 		for (let i = selectArr.length-1; i >= 0 ; i--) {
			// 			if(selectArr[i] != ""){
			// 				if(this.checkAddress(selectArr[i],selectArr[selectArr.length-2])){
			// 					this.showAddress.push(selectArr[i]);
			// 					this.useAddress.push(selectArr.join("、"));
			// 				}
			// 				break;
			// 			}
			// 		}
			// 	}
			// });
		},
		//校验地区
		checkAddress(address, province){
			for (let x of this.showAddress) {
				if(address == x){
					uni.showModal({
						title: "提示",
						content: "地区已选择!",
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					
					return false;
				}
				if("全国" == x){
					uni.showModal({
						title: "提示",
						content: "该地区已被所选地区包含，无法选择!",
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					
					return false;
				}
				if(province == x){
					uni.showModal({
						title: "提示",
						content: "该地区已被所选地区包含，无法选择!",
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					
					return false;
				}
			}
			if(this.showAddress.length > 0 && address == "全国" || address == ""){
				console.log("jinlaile");
				this.showAddress = [];
				this.useAddress = [];
			}
			if(address.indexOf("省") != -1 || address.indexOf("自治区") != -1){
				for (let i = this.useAddress.length-1; i >= 0; i--) {
					if(this.useAddress[i].indexOf(address) >= 0){
						this.useAddress.splice(i,1);
						this.showAddress.splice(i,1);
					}
				}
			}
			return true;
		},
		delAddress(item){
			uni.showModal({
				title: "",
				content: "确定删除?",
				showCancel:true,
				success: function (res) {
					var that = this
					if (res.confirm) {
						console.log('用户点击确定');
						this.showAddress.splice(item,1);
						this.useAddress.splice(item,1);
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}.bind(this)
			});
		}
	}
}
</script>

<style>
	.personal .img {
	    width: 150rpx;
	    height: 150rpx;
	    margin: 30rpx auto;
	    position: relative;	
	}
	.personal .img .touxiang{
	    width: 100%;
	    height: 100%;
	    border-radius: 50%;
	    overflow: hidden;
	}
	
	.personal .img .icon {
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		bottom: 0;
		right: 0;
		z-index: 1;
	}
	.personal .dl {
		padding: 0 35rpx;
	}
	.personal .dd {
		height: 100rpx;
		border-bottom: 1px solid #ebebeb;
		line-height: 100rpx;
		display: flex;
		/* justify-content: space-between; */
	}
	.personal .dd .span {
	    flex-shrink: 0;
	    width: 120rpx;
	    text-align: right;
	    margin-right: 50rpx;
	    color: #1a1a1a;
	    font-size: 30rpx;
	}
	.personal .dd .label {
	    width: 100%;
	    flex-shrink: 1;
	    border: 0;
	    height: 100rpx;
	    background: #e6e7e8;
	    font-size: 30rpx;
	}
	.red-star {
		color: red;
		/* margin-left: -15rpx; */
		font-size: 30rpx;
	}
	.personal .dd input {
	    width: 100%;
	    flex-shrink: 1;
	    border: 0;
	    height: 100rpx;
	    font-size: 30rpx;
	}
	.personal .next {
	    display: block;
	    /* position: fixed; */
	    bottom: 0;
	    left: 50%;
	    /* width: 10rem; */
	    /* margin-left: -5rem; */
	    background: #029e9d;
	    text-align: center;
	    line-height: 100rpx;
	    color: #fff;
	    font-size: 30rpx;
	}
	
	
	
	.license {
		margin: 0.2rem auto;
		position: relative;
		height: 100%;
	}
	.dd-license {
		margin: 1.2em auto;
		height: auto;
	}
	.div-license input {
		position: absolute;
		top: 0;
		right: 0;
		width: 100%;
		height: 100%;
		opacity: 0;
	}
	.div-license .license {
		width: 2.133333rem;
		height: 2.133333rem;
		margin: 1.2rem auto;
		position: relative;
	}
	.div-license .touxiang {
		width: 100%;
		height: 100%;
		border-radius: 50%;
		overflow: hidden;
	}

	.div-license .icon {
		width: 0.533333rem;
		height: 0.533333rem;
		position: absolute;
		bottom: 0;
		right: 0;
		z-index: 1;
	}

	.loader {
		position: relative;
		margin: 0 auto;
		width: 60px;
	}

	.loader:before {
		content: '';
		display: block;
		padding-top: 100%;
	}

	.circular {
		animation: rotate 2s linear infinite;
		height: 100%;
		transform-origin: center center;
		width: 100%;
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		margin: auto;
	}

	.path {
		stroke-dasharray: 1, 200;
		stroke-dashoffset: 0;
		animation: dash 1.5s ease-in-out infinite,
		color 6s ease-in-out infinite;
		stroke-linecap: round;
	}

	@keyframes rotate {
		100% {
			transform: rotate(360deg);
		}
	}

	@keyframes dash {
		0% {
			stroke-dasharray: 1, 200;
			stroke-dashoffset: 0;
		}
		50% {
			stroke-dasharray: 89, 200;
			stroke-dashoffset: -35px;
		}
		100% {
			stroke-dasharray: 89, 200;
			stroke-dashoffset: -124px;
		}
	}

	@keyframes color {
		100%,
		0% {
			stroke: #45494a;
		}
		40% {
			stroke: #45494a;
		}
		66% {
			stroke: #45494a;
		}
		80%,
		90% {
			stroke: #45494a;
		}
	}

	body {
		background-color: #eee;
	}

	.showbox {
		width: 700px;
		height: 200px;
		position: fixed;
		left: 50%;
		top: 50%;
		z-index: 9999;
		/*设定这个view的margin-top的负值为自身的高度的一半,margin-left的值也是自身的宽度的一半的负值.*/
		/*宽为400,那么margin-top为-200px*/
		/*高为200那么margin-left为-100px;*/
		margin: -100px 0 0 -350px;
	}

	.audit{
		width: 150rpx;
		font-size: 30rpx;
		color: red;
		position: absolute;
		top: 150rpx;
		text-align: center;
	}
	.address{
		list-style: none;
		width: 100%;
		line-height: 100rpx;
		/* margin-top: 0.1rem; */
	}
	.address li{
		display: inline-block;
		justify-content: center;
		align-items: center;
		margin-right: 0.26rem;
	}
	.titleWord{
		text-align-last: justify;
		padding-left: 0.1rem;
	}
	.personal .uploadBox {
	    overflow: hidden;
		padding: 0.4rem 0;
	}
	.personal .uploadBox .tit {
	    line-height: 200rpx;    
		float: left;
		display: flex;
	}
	.personal .uploadBox .upload {
	    float: right;
	    position: relative;
	}
</style>